Password Reset Package


There's no built-in password reset functionality in MDriven Turnkey. Add this pattern to your model that you can adapt as needed.

If you use the default package for login, the ASPNETIdentity package, this package will extend your model with the following:

  1. A reset password page that you can create an action to go to. This page should not have any access groups.
  2. A server-side ViewModel that runs every 20 seconds and sends emails with reset instructions to your users. Remember to set the Turnkey/MDrivenServer's email server settings.
  3. A page for the user to set the password. This page also has information for the user about expired reset tickets and sending new tickets in those circumstances.
Password Reset Package Pattern

Usage

  1. Merge the pattern into your model from the TK Live View
  2. Set the PasswordReset package's "Default superclass" if you want that.
  3. Make sure you have an email server set up and update the email settings of the MDriven Server.
  4. Create an action that opens the "ResetPasswordPage" ViewModel.
  5. Open the SS_ResetPassword ViewModel and update the from Column expression to the email of the sender string.

Email Settings

Goto your MDriven Server control panel -> Running -> then Model and edit fields for the email settings.

MDriven Server Email Settings

ServerSide ViewModel to Send Emails

server side view model for sending emails

ResetPasswordTicket

Attributes

Expires: DateTime?

This is the expiring DateTime of the ResetPasswordTicket.

ResetAuthorizationCode: String?

This is the token used for identifying user's reset password tickets. It is unique for every ticket.

ResetLog: Text?

This is for tracking the state changes of the password reset request process.

ResetPasswordURL: String?

This is the URL used to reset the password.

Sent: DateTime?

This is the DateTime the email that contains the password reset url was sent to the user.

vNewPassword: String?

Captures the new password to be set for the user.

vNewPasswordConfirm: String?

Copy of password to confirm new password.

/CanNewTicketBeSent: Boolean

Derived attribute to determine if a new password reset ticket can be sent by checking if they are no existing tickets waiting to sent or tickets that have been sent.

/IsValid: Boolean

Derived attribute to check ticket has not yet expired.

/ShowDoneUI: Boolean

Derived attribute used to show the DONEUI when password has been reset.

/ShowResetUI: Boolean

Derived attribute used to show Reset password UI with new password fields.

Methods

AddToLog

Arg: aText - Text to add to log

This is used to add content to the ResetLog attribute.

GetExpiresInMinutes: Integer

This is used to get the number of minutes it will take for the reset password ticket to expire.

OnCreate

This is used to set the ResetAuthorizationCode, ResetPasswordURL and Expires attributes. Default expiry time is 120 minutes. Adjust this to your suiting.

OnStateChange

This is used to capture state changes stored in the ResetLog attribute.

SysUser

Methods

GetResetPasswordTicket: ResetPasswordTicket

Triggers the ResetPasswordTicket State Machine to expire any password reset requests are past their expiry time.

This method returns the user's ResetPasswordTicket that has been sent if any is available otherwise creates a new ResetPasswordTicket

HashPassword: String

Arg: pwd:String - password to hash

This is used to hash a user's password

SetPassword

Arg: pwd:String - new password to set

This is used to set a new PasswordHash for a user using the HashPassword method.

See also:

  • SysUserAuthentication Package
  • ASP.NET Identity Package

Download the model file here: Model_Examples

This page was edited 8 days ago on 12/13/2024. What links here